<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //   const obj = {
      //     name: "奉仙",
      //     age: 21,
      //   };
      //   console.log(obj.name);
      //   console.log(obg.age);

      //   // 解构
      //   const { name, age } = { name: "奉仙", age: 21 };
      //   // 要求属性名和变量名必须一致
      //   console.log(name);
      //   console.log(age);

      //   // 对象解构的变量名可以改重新改名 旧变量名 ： 新变量名
      //   const { name: name2, age } = { name: "奉仙", age: 21 };
      //   console.log(name2);
      //   console.log(age);

      // 解构数组对象
      const obj = [
        {
          name: "奉仙",
          age: 21,
        },
      ];
      const [{ name, age }] = obj;
      console.log(name);
      console.log(age);
    </script>
  </body>
</html>
